package com.mine.modules.vm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mine.modules.vm.domain.query.MonitorPageQuery;
import com.mine.modules.vm.domain.query.MonitorPreviewURLsQuery;
import com.mine.common.domain.vo.Result;
import com.mine.modules.vm.entity.VmMonitor;
import com.mine.modules.vm.service.IVmMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author xujf
 * @since 2024-09-22
 */
@RestController
@RequestMapping("/vm/monitor")
@RequiredArgsConstructor
@Api(tags = "视频监控")
public class VmMonitorController {

    private final IVmMonitorService monitorService;

    @ApiOperation(value="分页获取监控点资源", notes="分页获取监控点资源")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<?> queryPageList(MonitorPageQuery monitorPageQuery) {
        return monitorService.queryPageList(monitorPageQuery);
    }

    @ApiOperation(value="获取监控分类树形列表", notes="获取监控分类树形列表")
    @RequestMapping(value = "/treeList", method = {RequestMethod.GET})
    public Result<?> treeAllList() {
        return monitorService.treeAllList();
    }

    @ApiOperation(value="获取监控点预览取流", notes="获取监控点预览取流")
    @RequestMapping(value = "/getPreviewURLs", method = {RequestMethod.GET})
    public Result<String> getPreviewURLs(MonitorPreviewURLsQuery previewURLsQuery) {
        return monitorService.getPreviewURLs(previewURLsQuery);
    }

    @ApiOperation(value = "绑定监控场景图层id", notes = "绑定监控场景图层id")
    @RequestMapping(value = "/bindSceneLayerOfMonitor", method = {RequestMethod.GET})
    public Result<?> bindSceneLayerOfMonitor(@RequestParam String monitorId, @RequestParam(required = false) String sceneLayerId) {
        return monitorService.bindSceneLayerOfMonitor(monitorId, sceneLayerId);
    }

    @ApiOperation(value = "通过场景图层id查询监控详情", notes = "通过场景图层id查询监控详情")
    @RequestMapping(value = "/getDetailsBySceneLayerId", method = {RequestMethod.GET})
    public Result<?> getDetailsBySceneLayerId(@RequestParam String sceneLayerId) {
        return monitorService.getDetailsBySceneLayerId( sceneLayerId);
    }

    @ApiOperation(value = "监控资源同步", notes = "监控资源同步")
    @RequestMapping(value = "/monitorSyn", method = {RequestMethod.GET})
    public void monitorSyn() {
        monitorService.synCameras();
    }

    @ApiOperation(value = "设置视角", notes = "设置视角")
    @RequestMapping(value = "/setAngleView", method = {RequestMethod.GET})
    public Result<?> setAngleView(@RequestParam String id, @RequestParam(required = false) String angleView) {
        return monitorService.setAngleView(id, angleView);
    }

}
